﻿@using Nop.Core.Domain.Catalog
@model OrderModel.AddOrderProductModel.ProductDetailsModel
@{
    //page title
    ViewBag.Title = string.Format(T("Admin.Orders.Products.AddNew.Title2").Text, Model.Name, Model.OrderId);
}
@*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@
@using (Html.BeginForm("AddProductToOrderDetails", "Order",
    new RouteValueDictionary(new { orderId = Model.OrderId, productId = Model.ProductId }),
    FormMethod.Post,
    new Dictionary<string, Object> { { "enctype", "multipart/form-data" } }))
{
    @Html.ValidationSummary(false)
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Administration/Content/images/ico-sales.png")" alt="" />
            @string.Format(T("Admin.Orders.Products.AddNew.Title2").Text, Model.Name, Model.OrderId)
            @Html.ActionLink("(" + T("Admin.Orders.Products.AddNew.BackToList") + ")", "AddProductToOrder", new { orderId = Model.OrderId })
        </div>
        <div class="options">
        </div>
    </div>
    <div>
        @if (Model.Warnings.Count > 0)
        {
            <div class="messageBox messageBoxError">
                @foreach (var warning in Model.Warnings)
                {
                    @warning
                    <br />
                }
            </div>
        }
    </div>
        if (Model.ProductType == ProductType.SimpleProduct)
        {
    <div>
        <table>
            <tr>
                <td>
                    @Html.NopLabelFor(model => model.UnitPriceInclTax):
                </td>
                <td>
                    @Html.EditorFor(model => model.UnitPriceInclTax)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.NopLabelFor(model => model.UnitPriceExclTax):
                </td>
                <td>
                    @Html.EditorFor(model => model.UnitPriceExclTax)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.NopLabelFor(model => model.Quantity):
                </td>
                <td colspan="2">
                    @Html.EditorFor(model => model.Quantity)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.NopLabelFor(model => model.SubTotalInclTax):
                </td>
                <td>
                    @Html.EditorFor(model => model.SubTotalInclTax)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.NopLabelFor(model => model.SubTotalExclTax):
                </td>
                <td>
                    @Html.EditorFor(model => model.SubTotalExclTax)
                </td>
            </tr>
        </table>
        <div>
            @Html.Partial("_ProductAddAttributes", Model.ProductVariantAttributes)
        </div>
        @{
            var dataDictGiftCard = new ViewDataDictionary();
            dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = "giftcard";
            @Html.Partial("_ProductAddGiftCardInfo", Model.GiftCard, dataDictGiftCard)
        }
        <p>
            <strong>@T("Admin.Orders.Products.AddNew.Note2")</strong>
        </p>
        <input type="submit" class="k-button" value="@T("Admin.Orders.Products.AddNew")" />
    </div>
        }
        else if (Model.ProductType == ProductType.GroupedProduct)
        {
    <div>
        @*TODO add support for grouped products to be added to an existing order*@
        Grouped products are not currently supported for adding to an existing order
    </div>
        }
        else
        {
    <div>
        This product type (unknown) is not currently supported for adding to an existing order
    </div>
        }
}